﻿using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ShevaEngine.Core.Modules.Graphics.Foundation;
using ShevaEngine.Core.Modules.Materials;


namespace ShevaDeferredRenderer.PostProcess
{
    /// <summary>
    /// Über post processing effect.
    /// </summary>
    public class PostProcessing
    {
        /// <summary>Effect.</summary>
        private Effect Effect;        

        /// <summary>
        /// Constructor.
        /// </summary>
        internal PostProcessing()
        {
            this.Effect = MaterialManager.Instance.GetEffect("PostProcessSimple");
            this.Effect.Parameters["World"].SetValue(Matrix.Identity);
            this.Effect.Parameters["View"].SetValue(Matrix.Identity);
            this.Effect.Parameters["Proj"].SetValue(Matrix.Identity);
        }

        /// <summary>
        /// Render.
        /// </summary>
        public void Render(RenderTarget2D sceneTexture)
        {
            ShevaEngine.Core.ShevaEngine.Instance.GraphicsDevice.BlendState = BlendState.Opaque;
            ShevaEngine.Core.ShevaEngine.Instance.GraphicsDevice.DepthStencilState = DepthStencilState.None;

            this.Effect.Parameters["Diffuse"].SetValue(sceneTexture);

            this.Effect.CurrentTechnique.Passes[0].Apply();
   
            ScreenPlane.Instance.Render();            
        }
    }
}
